home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2462 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: newsstand.tc.umn.edu!dyue
  2. From: dyue@cs.umn.edu (Dongxiao Yue)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: When to use "->" vs "." when calling Member functions
  5. Date: 17 Jan 1996 23:01:20 GMT
  6. Organization: University of Minnesota
  7. Message-ID: <4djv40$jpa@epx.cis.umn.edu>
  8. References: <4dhea1$6v8@ornews.intel.com> <30FCB569.41C67EA6@intellektik.informatik.th-darmstadt.de>
  9. NNTP-Posting-Host: exa.cs.umn.edu
  10.  
  11. Enno Sandner <enno@intellektik.informatik.th-darmstadt.de> writes:
  12.  
  13. >Thurman Miller wrote:
  14. >> 
  15. >> I'm confused, so please no harsh remarks :)
  16. >> 
  17. >> If I've got:
  18. >> 
  19. >> class Cfoo
  20. >> {
  21. >>         something * getptr();
  22. >>         somethingelse* m_other;
  23. >> }
  24. >> 
  25. >> something * foo::getptr()
  26. >> {
  27. >>         return m_other;
  28. >> }
  29. >> 
  30. >> Now...if I'm in another class....
  31. >> 
  32. >>         Cfoo foo;
  33. >>         somethingelse* = foo.getptr();
  34. >> 
  35. >> why doesn't the following work?
  36. >> 
  37. >>         somethingelse* = foo->getptr();
  38. >> 
  39. >> I get compile error about no "->" overloaded operator....
  40. >> 
  41. >> Can someone point out the obvious when I use one notation over
  42. >> another?
  43. >> 
  44.  
  45. >If you want to use 'foo.f' where 'f' is some member of a class,
  46. >'foo' must be an instance or reference to that class. If 'foo'
  47. >is a pointer to a class you must use 'foo->f' to access the member 'f'.
  48.  
  49. >    Enno
  50.  
  51.     When you see foo->f,  foo may not be a pointer.
  52.